import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import Layout from '@/layout/index.vue'

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    children: [
      {
        path: '/index',
        name: 'index',
        component: () => import('@/views/index'),
        meta: { title: '首頁', icon: 'index' }
      },
      {
        path: '/staff',
        name: 'staff',
        component: () => import('@/views/staff-management/index.vue'),
        meta: { title: '員工管理', icon: 'staff' }
      },
      {
        path: '/customer',
        name: 'customer',
        component: () => import('@/views/customer-management/index.vue'),
        meta: { title: '客户管理', icon: 'customer' }
      },
      {
        path: '/customer-detail',
        name: 'customer-detail',
        component: () => import('@/views/customer-management/customer-detail.vue'),
        hidden: true
      },
      {
        path: '/staff-detail',
        name: 'staff-detail',
        component: () => import('@/views/staff-management/staff-detail.vue'),
        hidden: true
      },
      {
        path: '/quotation',
        name: 'quotation-management',
        component: () => import('@/views/quotation-management/index.vue'),
        meta: { title: '報價管理', icon: 'quotation' }
      },
      {
        path: '/invoice',
        name: 'invoice-management',
        component: () => import('@/views/invoice-management/index.vue'),
        meta: { title: '發票管理', icon: 'invoice' }
      },
      {
        path: '/service',
        name: 'service-management',
        component: () => import('@/views/service-management/index.vue'),
        meta: { title: '服務管理', icon: 'service' }
      },
      {
        path: '/activities',
        name: 'activities',
        component: () => import('@/views/activities-management/index.vue'),
        meta: { title: '活動專案管理', icon: 'activities' }
      },
      {
        path: '/receipt',
        name: 'receipt-management',
        component: () => import('@/views/receipt-management/index.vue'),
        meta: { title: '收據管理', icon: 'receipt' }
      },
      {
        path: '/supplier',
        name: 'supplier-management',
        component: () => import('@/views/supplier-management/index.vue'),
        meta: { title: '供應商管理', icon: 'supplier' }
      },
      {
        path: '/order',
        name: 'order-management',
        component: () => import('@/views/order-management/index.vue'),
        meta: { title: '訂單管理', icon: 'order' }
      },
      {
        path: '/data-analysis',
        name: 'data-analysis-management',
        component: () => import('@/views/data-analysis-management/index.vue'),
        meta: { title: '數據分析管理', icon: 'data-analysis' }
      },
      {
        path: '/cost',
        name: 'cost-management',
        component: () => import('@/views/cost-management/index.vue'),
        meta: { title: '成本管理', icon: 'cost' }
      },
      {
        path: '/e-management',
        name: 'email-management',
        component: () => import('@/views/email-management/index.vue'),
        meta: { title: '郵件設置管理', icon: 'email' },
        children: [
          {
            path: '/send',
            name: 'send',
            component: () => import('@/views/email-management/preinstall/send.vue'),
            meta: { title: '抄送/密送預設', icon: 'e-send' }
          },
          {
            path: '/email',
            name: 'email',
            component: () => import('@/views/email-management/preinstall/email.vue'),
            meta: { title: '郵件預設', icon: 'e-email' }
          },
          {
            path: '/signature',
            name: 'signature',
            component: () => import('@/views/email-management/preinstall/signature.vue'),
            meta: { title: '簽名預設', icon: 'e-signature' }
          }
        ]
      },
      {
        path: '/account',
        name: 'account-management',
        component: () => import('@/views/account-management/index.vue'),
        meta: { title: '賬號管理', icon: 'account' }
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/login.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/register/register.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
